Skip to content

Fixed detection of optional chains containing a reference - #64232

Open
Mateusz Burzyński (Andarist) wants to merge 3 commits into
microsoft:mainfrom
Andarist:port-59144-optional-chain-reference
Open

Mateusz Burzyński (Andarist) wants to merge 3 commits into
microsoft:mainfrom
Andarist:port-59144-optional-chain-reference

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

fixes #56998
fixes #60855

recreates #59144

Copilot AI balanced review requested due to automatic review settings September 10, 2026 16:53
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 10, 2026
@typescript-automation typescript-automation Bot added the For Backlog Bug PRs that fix a backlog bug label Sep 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The operand reversal regresses narrowing when an optional-chain base is wrapped in a satisfies expression.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes control-flow narrowing for references assigned within optional-chain bases.

Changes:

  • Reverses reference matching to recognize assignment targets.
  • Adds regression and negative narrowing tests with baselines.
File summaries
File Description
tsc/internal/checker/flow.go Updates optional-chain reference matching.
tsc/testdata/tests/cases/conformance/controlFlow/controlFlowOptionalChain4.ts Adds regression cases.
tsc/testdata/baselines/reference/conformance/controlFlowOptionalChain4.types Records inferred types.
tsc/testdata/baselines/reference/conformance/controlFlowOptionalChain4.symbols Records resolved symbols.
tsc/testdata/baselines/reference/conformance/controlFlowOptionalChain4.errors.txt Records expected diagnostics.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread tsc/internal/checker/flow.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused checker correction is supported by comprehensive positive and negative regression baselines.

Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Sep 15, 2026
@jakebailey

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it

@typescript-automation

typescript-automation Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
test top400 ✅ Started ✅ Results
user test this ✅ Started ✅ Results
run dt ✅ Started
perf test this faster ✅ Started 👀 Results

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - native
Errors 41 41 ~ ~ ~ p=1.000 n=12
Symbols 115,480 115,480 ~ ~ ~ p=1.000 n=12
Types 96,945 96,945 ~ ~ ~ p=1.000 n=12
Memory Used 148,628k (± 0.46%) 148,126k (± 0.49%) ~ 146,707k 150,362k p=0.198 n=12
Memory Allocs 2,271,272 (± 0.00%) 2,271,232 (± 0.01%) ~ 2,270,935 2,271,445 p=0.887 n=12
Config Time 0.000s (±217.90%) 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.051s (± 3.79%) 0.051s (± 3.11%) ~ 0.046s 0.054s p=0.899 n=12
Bind Time 0.016s (±12.37%) 0.016s (±11.92%) ~ 0.013s 0.021s p=0.925 n=12
Check Time 0.597s (± 0.98%) 0.602s (± 0.73%) ~ 0.591s 0.610s p=0.103 n=12
Emit Time 0.329s (± 2.63%) 0.328s (± 1.70%) ~ 0.312s 0.339s p=0.966 n=12
Total Time 1.000s (± 0.67%) 1.004s (± 0.88%) ~ 0.982s 1.029s p=0.354 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 847,422 (± 0.06%) 847,765 (± 0.08%) ~ 844,736 848,512 p=0.128 n=12
Types 249,851 (± 0.00%) 249,851 (± 0.00%) ~ 249,849 249,861 p=0.376 n=12
Memory Used 793,676k (± 0.08%) 793,679k (± 0.06%) ~ 792,649k 795,382k p=0.843 n=12
Memory Allocs 12,954,108 (± 0.02%) 12,956,530 (± 0.06%) ~ 12,948,452 12,989,228 p=0.671 n=12
Config Time 0.020s (± 0.91%) 0.020s ~ ~ ~ p=1.000 n=12
Parse Time 0.343s (± 3.00%) 0.348s (± 2.28%) ~ 0.325s 0.362s p=0.434 n=12
Bind Time 0.082s (±17.71%) 0.075s (± 5.33%) ~ 0.069s 0.094s p=0.280 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.968s (± 1.06%) 1.958s (± 0.62%) ~ 1.936s 2.007s p=0.560 n=12
Total Time 2.431s (± 1.27%) 2.418s (± 0.62%) ~ 2.391s 2.481s p=0.921 n=12
mui-docs - native
Errors 11,315 (± 0.06%) 11,319 (± 0.04%) ~ 11,299 11,323 p=0.635 n=12
Symbols 4,082,255 4,082,255 ~ ~ ~ p=1.000 n=12
Types 1,497,312 1,497,312 ~ ~ ~ p=1.000 n=12
Memory Used 4,079,435k (± 0.04%) 4,079,616k (± 0.03%) ~ 4,076,745k 4,083,511k p=0.977 n=12
Memory Allocs 43,636,964 (± 0.05%) 43,626,760 (± 0.03%) ~ 43,604,253 43,667,329 p=0.590 n=12
Config Time 0.019s 0.019s (± 0.95%) ~ 0.019s 0.020s p=1.000 n=12
Parse Time 0.670s (± 2.29%) 0.680s (± 1.44%) ~ 0.654s 0.702s p=0.339 n=12
Bind Time 0.003s (±27.24%) 0.002s (±13.40%) ~ 0.002s 0.003s p=1.000 n=12
Check Time 16.916s (± 0.27%) 16.882s (± 0.39%) ~ 16.699s 17.042s p=0.319 n=12
Emit Time 0.543s (±10.70%) 0.524s (± 2.56%) ~ 0.512s 0.570s p=0.502 n=12
Total Time 19.070s (± 0.23%) 19.039s (± 0.12%) ~ 18.987s 19.093s p=0.193 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,394,252 1,394,252 ~ ~ ~ p=1.000 n=12
Types 443,418 443,418 ~ ~ ~ p=1.000 n=12
Memory Used 1,647,910k (± 0.33%) 1,646,605k (± 0.37%) ~ 1,631,090k 1,665,144k p=0.799 n=12
Memory Allocs 97,049,303 (± 0.04%) 97,065,456 (± 0.05%) ~ 96,937,094 97,210,142 p=0.671 n=12
Config Time 0.004s (±12.88%) 0.004s (±12.60%) ~ 0.003s 0.006s p=0.484 n=12
Parse Time 0.192s (± 2.42%) 0.196s (± 2.50%) ~ 0.188s 0.212s p=0.147 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.808s (± 0.34%) 1.811s (± 0.28%) ~ 1.799s 1.828s p=0.418 n=12
Emit Time 0.280s (± 4.94%) 0.284s (± 4.17%) ~ 0.245s 0.303s p=0.600 n=12
Total Time 24.792s (± 0.53%) 24.917s (± 0.50%) ~ 24.652s 25.263s p=0.178 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 337,531 337,531 ~ ~ ~ p=1.000 n=12
Types 198,830 198,830 ~ ~ ~ p=1.000 n=12
Memory Used 319,648k (± 0.08%) 319,531k (± 0.07%) ~ 319,183k 320,604k p=0.143 n=12
Memory Allocs 4,673,076 (± 0.01%) 4,672,821 (± 0.01%) ~ 4,671,098 4,674,085 p=0.514 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.112s (± 4.39%) 0.113s (± 3.72%) ~ 0.099s 0.122s p=0.765 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.054s (± 0.42%) 1.052s (± 0.44%) ~ 1.039s 1.061s p=0.811 n=12
Emit Time 0.124s (±12.37%) 0.140s (±11.90%) ~ 0.098s 0.169s p=0.117 n=12
Total Time 1.346s (± 1.01%) 1.359s (± 1.15%) ~ 1.315s 1.396s p=0.173 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 305,179 305,179 ~ ~ ~ p=1.000 n=12
Types 181,876 181,876 ~ ~ ~ p=1.000 n=12
Memory Used 277,220k (± 0.01%) 277,170k (± 0.02%) ~ 277,068k 277,322k p=0.114 n=12
Memory Allocs 1,641,789 (± 0.01%) 1,641,872 (± 0.01%) ~ 1,641,460 1,642,255 p=0.410 n=12
Config Time 0.001s (±65.70%) 0.001s (±65.70%) ~ 0.000s 0.001s p=1.000 n=12
Parse Time 0.102s (± 3.59%) 0.100s (± 4.22%) ~ 0.091s 0.110s p=0.449 n=12
Bind Time 0.038s (±12.40%) 0.037s (±11.41%) ~ 0.027s 0.052s p=0.521 n=12
Check Time 0.836s (± 0.78%) 0.841s (± 0.42%) ~ 0.828s 0.849s p=0.354 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.990s (± 0.81%) 0.992s (± 0.70%) ~ 0.972s 1.004s p=0.504 n=12
vscode - native
Errors 351 351 ~ ~ ~ p=1.000 n=12
Symbols 8,856,348 8,856,348 ~ ~ ~ p=1.000 n=12
Types 3,024,061 3,024,061 ~ ~ ~ p=1.000 n=12
Memory Used 5,925,595k (± 0.02%) 5,925,222k (± 0.01%) ~ 5,923,689k 5,926,474k p=0.887 n=12
Memory Allocs 45,575,813 (± 0.02%) 45,565,779 (± 0.01%) ~ 45,558,771 45,580,204 p=0.052 n=12
Config Time 0.053s (± 0.34%) 0.053s (± 0.34%) ~ 0.052s 0.053s p=1.000 n=12
Parse Time 1.336s (± 2.85%) 1.359s (± 2.59%) ~ 1.286s 1.458s p=0.224 n=12
Bind Time 0.414s (±13.23%) 0.370s (±15.22%) ~ 0.302s 0.530s p=0.263 n=12
Check Time 9.175s (± 1.27%) 9.273s (± 1.40%) ~ 9.012s 9.544s p=0.325 n=12
Emit Time 3.957s (± 9.22%) 3.514s (±11.09%) ~ 2.782s 4.431s p=0.068 n=12
Total Time 15.030s (± 1.81%) 14.658s (± 1.98%) -0.372s (- 2.48%) 14.088s 15.419s p=0.040 n=12
webpack - native
Errors 837 837 ~ ~ ~ p=1.000 n=12
Symbols 1,125,807 1,125,807 ~ ~ ~ p=1.000 n=12
Types 480,798 480,798 ~ ~ ~ p=1.000 n=12
Memory Used 814,023k (± 0.02%) 813,931k (± 0.02%) ~ 813,308k 814,308k p=0.319 n=12
Memory Allocs 5,145,772 (± 0.03%) 5,146,027 (± 0.04%) ~ 5,143,713 5,154,767 p=0.843 n=12
Config Time 0.007s 0.007s ~ ~ ~ p=1.000 n=12
Parse Time 0.189s (± 3.80%) 0.189s (± 2.21%) ~ 0.177s 0.203s p=0.921 n=12
Bind Time 0.053s (±20.84%) 0.050s (±16.55%) ~ 0.038s 0.073s p=0.679 n=12
Check Time 1.362s (± 0.31%) 1.367s (± 0.69%) ~ 1.331s 1.391s p=0.309 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.640s (± 0.56%) 1.642s (± 0.88%) ~ 1.603s 1.679s p=1.000 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,045,691 1,045,691 ~ ~ ~ p=1.000 n=12
Types 381,854 381,854 ~ ~ ~ p=1.000 n=12
Memory Used 611,084k (± 0.01%) 611,177k (± 0.02%) ~ 610,861k 611,426k p=0.132 n=12
Memory Allocs 4,827,173 (± 0.05%) 4,826,257 (± 0.06%) ~ 4,822,651 4,835,877 p=0.347 n=12
Config Time 0.002s 0.002s ~ ~ ~ p=1.000 n=12
Parse Time 0.115s (± 3.79%) 0.118s (± 3.57%) ~ 0.105s 0.128s p=0.368 n=12
Bind Time 0.036s (±20.15%) 0.033s (±19.42%) ~ 0.024s 0.059s p=0.463 n=12
Check Time 0.989s (± 0.58%) 0.987s (± 0.71%) ~ 0.973s 1.010s p=0.599 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.151s (± 0.78%) 1.148s (± 0.74%) ~ 1.129s 1.166s p=0.640 n=12
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • mui-docs - native
  • strada-build-src - native
  • strada-compiler - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 12
Baseline baseline 12

Developer Information:

Download Benchmarks

@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing main and refs/pull/64232/merge:

There were infrastructure failures potentially unrelated to your change:

  • 2 instances of "Package install failed"
  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Sep 15, 2026
@jakebailey
Jake Bailey (jakebailey) removed this pull request from the merge queue due to a manual request Sep 15, 2026
@typescript-automation

Copy link
Copy Markdown
Contributor

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/64232/merge:

Everything looks good!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog Bug PRs that fix a backlog bug

Projects

Status: Needs merge

3 participants